#ifndef WXSCODEGENERATOR_H
#define WXSCODEGENERATOR_H

#include "wxscodercontext.h"

#include <prep.h>


class wxsCodeGenerator {
  public:


    wxsCodeGenerator();


    virtual ~wxsCodeGenerator();


    void BuildCode( wxsCoderContext* Context );

  protected:

    virtual void OnBuildCreatingCode() = 0;              ///< \brief Building code manually creating resource, it may also be used to add header files
    virtual void OnBuildHeadersCode() {}                 ///< \brief Building headers arrays, it's not required since headers can be added in OnBuildCreatingCode()
    virtual void OnBuildDeclarationsCode() = 0;          ///< \brief Building variable declaration / forward declaration
    virtual void OnBuildEventsConnectingCode() = 0;      ///< \brief Building code connecting events
    virtual void OnBuildIdCode() = 0;                    ///< \brief Building code declaring class members and values of identifiers
    virtual void OnBuildXRCFetchingCode() = 0;           ///< \brief Building code which fetches this item from xrc resource
    virtual void OnUpdateFlags( M_Code_unused long& Flags ) {}

    inline wxsCoderContext* GetCoderContext() { return m_Context; }


    inline wxsCodingLang GetLanguage() { return m_Context ? m_Context->m_Language : wxsUnknownLanguage; }


    inline long GetCoderFlags() { return m_Context ? m_Context->m_Flags : 0; }


    inline void AddHeader( const wxString& Header, const wxString& DeclaredClass, long HeaderFlags = 0 ) {
      if( GetCoderContext() ) {
        GetCoderContext()->AddHeader( Header, DeclaredClass, HeaderFlags );
      }
    }


    inline void AddDeclaration( const wxString& Declaration ) {
      if( GetCoderContext() ) {
        GetCoderContext()->AddDeclaration( Declaration );
      }
    }


    inline void AddXRCFetchingCode( const wxString& Code ) {
      if( GetCoderContext() ) {
        GetCoderContext()->AddXRCFetchingCode( Code );
      }
    }


    inline void AddBuildingCode( const wxString& Code ) {
      if( GetCoderContext() ) {
        GetCoderContext()->AddBuildingCode( Code );
      }
    }


    inline void AddEventCode( const wxString& Code ) {
      if( GetCoderContext() ) {
        GetCoderContext()->AddEventCode( Code );
      }
    }


    inline void AddIdCode( const wxString& Enumeration, const wxString& Initialization ) {
      if( GetCoderContext() ) {
        GetCoderContext()->AddIdCode( Enumeration, Initialization );
      }
    }

  private:

    wxsCoderContext* m_Context;
};

#endif
